package com.shop.controller;

import com.shop.Service.LogService;
import com.shop.pojo.Log;
import com.shop.pojo.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@CrossOrigin
@Controller
@RequestMapping("/api/log")
public class LogController {

    @Autowired
    private LogService logService;

    @PostMapping("/selectLog")
    @ResponseBody
    public Message<List<Log>> selectLog(@RequestBody Map<String,Object> map) throws Exception{
        Message<List<Log>> message = new Message<>();
        int limit =  Integer.parseInt(map.get("limit").toString());
        message = logService.selectLog(limit);
        message.setStatus("200");
        return message;
    }

}
